<?php include THEMES_PATH . 'public/before_body2.phtml'; ?>
<link href="/statics/front/css/product.css" rel="stylesheet">
</head>
<body>
<?php include THEMES_PATH . 'public/header2.phtml';?>
<div class="product-wrapper js-product-wrapper" style="background:#fff url(<?php echo $productInfo['bg_img']?>) no-repeat 50% 0;">
  <div class="clearfix main-width">
    <!--左侧信息栏-->
    <div class="product-info col-md-4 col-sm-6">
      <?php if($productInfo['display'] != 1):?><span class="sold-out"></span><?php endif;?>
      <span class="back-prev-page js-back">&lt; <?php echo L('back');?></span>
      <h1 class="title"><?php echo $productInfo['name'];?></h1>
      <div>
        <?php
          if($productComment['star'] > 0):
        ?>
          <span class="comment-star">
            <?php
              if($productComment['star'] == 0) $productComment['star'] = 5;
                for($star=0;$star<$productComment['star'];$star++):
            ?>
            <span class="fa fa-star"></span>
            <?php endfor;?>
            <?php for($star=0;$star<(5-$productComment['star']);$star++):?>
            <span class="fa fa-star-o"></span>
            <?php endfor;?>
          </span>
        <?php endif;?>
        <span>(<a class="comment-num" href="#product-comment"><?php if($productComment['count'] <= 0){echo L('No_review');}else if($productComment['count'] == 1){echo $productComment['count'].' '.L('Customer_Review');}else{echo $productComment['count'].' '.L('Customer_Reviews');}?></a>)</span>
      </div>
      <p class="title product-price"><?php echo currency($productInfo['custom_price']);?></p>
      <div class="vi-sm vi-xs mb1x rel carousel-mobile">
        <div class="ovh js-carousel" id="js-carousel-mobile">
          <ul class="rel">
            <?php
              if (isset($productInfo['photoList']) && $productInfo['photoList']):
                foreach ($productInfo['photoList'] as $i => $file):
                  if($i<=0){continue;}
            ?>
            <li>
              <img src="<?php echo $file['img']; ?>" class="vm">
            </li>
            <?php
                endforeach;
              endif;
            ?>
          </ul>
        </div>
        <p class="carousel-pagination js-carousel-pagination"></p>
      </div>
      <div class="mb1x align-right product-desc">
        <p><?php echo $productInfo['summary']; ?></p>
        <span class="hide js-view-more"><?php echo L('_View_More_'); ?></span>
      </div>
      <form action="javascript:addProductToCart(<?php echo isset($productInfo['id']) ? $productInfo['id'] : null ?>)" method="post" name="ECS_FORMBUY" id="ECS_FORMBUY">
        <div class="pro-qty">
          <span><?php echo L('goods_number')?>:</span>
          <i class="decrease js-decrease">－</i>
          <input type="text" name="qty" id="goods_number" value="1">
          <i class="increase js-increase">＋</i>
        </div>
        <button type="submit" class="btn btn-middle mt1x mb1x width-full<?php echo $productInfo['display'] == 0 ? ' disabled':'';?>"><?php echo L('addtocart');?></button>
      </form>
	    <?php
        $send_days = 9;
      ?>
      <p style="display:none;color:#eb6f00;"><span class="fa fa-exclamation-circle"></span> Receive by <?php echo date('M.jS,Y',strtotime('+'.$send_days.'days'));?> <br />5-week turnaround time from Feb. 5th to Mar. 5th</p>
      <div class="mt1x mb1x"><?php echo $productInfo['content'];?></div>
      <ul class="clearfix pt1x align-center border-top shopping-clause">
        <li>
          <span><?php echo L('receiver_by_november');?></span>
          <p><img src="/statics/front/images/icons/lightning.png" alt="<?php echo L('receiver_by_november');?>"/></p>
        </li>
        <li>
          <span><?php echo L('free_shipping');?></span>
          <p><img src="/statics/front/images/icons/shipment.png" alt="<?php echo L('free_shipping');?>"/></p>
        </li>
        <li>
          <span><?php if($productInfo['model_id'] == 25):?><?php echo L('_RETURN_EXCHANGE_POLICY_');?><?php else:?><?php echo L('fit_promise');?><?php endif;?></span>
          <p><img src="/statics/front/images/icons/fit.png" alt="<?php echo L('fit_promise');?>"></p>
        </li>
      </ul>
      <div class="mt1x sns">
        <p class="mb1x"><?php echo L('SHARE_GET');?></p>
        <ul class="clearfix align-center">
          <li>
            <a class="qzone" href="javascript:void(0);" onClick="window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(document.location.href));return false;" title="分享到QQ空间" rel="nofollow">
              <img src="/statics/front/images/icons/qqzone.png" alt="分享到QQ空间" class="vt">
            </a>
          </li>
          <li>
            <a class="weibo" href="javascript:void(0);" onClick="window.open('http://service.weibo.com/share/share.php?appkey=583395093&title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(document.location.href)+'&source=bshare&retcode=0&ralateUid=');return false;" title="分享到新浪微博" rel="nofollow">
              <img src="/statics/front/images/icons/weibo.png" alt="分享到新浪微博" class="vt">
            </a>
          </li>
        </ul>
      </div>
    </div>
    <!--右侧图片列表-->
    <div class="hi-sm hi-xs pro-gallery js-pro-gallery">
      <ul>
        <?php
        if (isset($productInfo['photoList']) && $productInfo['photoList']):
          foreach ($productInfo['photoList'] as $i => $file):
          if($i<=0){continue;};
        ?>
        <li><img src="<?php echo $file['thumb']; ?>"></li>
        <?php
          endforeach;
        endif;
        ?>
      </ul>
    </div>
  </div>
</div>
<div class="album js-album">
  <ul>
    <?php
      if (isset($productInfo['photoList']) && $productInfo['photoList']):
        foreach ($productInfo['photoList'] as $i => $file):
        if($i<=0){continue;}
    ?>
    <li>
      <img src="<?php echo $file['img']; ?>">
    </li>
    <?php
        endforeach;
      endif;
    ?>
  </ul>
  <i class="pull-left js-left"><?php echo L('left');?></i>
  <i class="pull-right js-right"><?php echo L('right');?></i>
  <span class="close js-close">×</span>
</div>
<!--产品评论-->
<div id="product-comment" class="product-comment main-width">
  <div class="heading product-comment-title">
    <strong><?php echo L('Customer_Reviews');?></strong>
  </div>
  <?php if($productComment['count'] < 1):?>
    <div class="no-comment align-center" >
      <?php echo L('No_reviews_here');?>
    </div>
  <?php endif;?>
</div>
<div class="main-width heading">
  <strong><?php echo L('_Also_Viewed_');?></strong>
</div>
<div class="ovh rel main-width align-center carousel-box">
  <div class="ovh carousel js-carousel">
    <ul class="rel">
      <?php
        if(isset($productList) && $productList):
          foreach ($productList as $key => $product):
            if(!$product){
              continue;
            }
      ?>
      <li>
        <a href="<?php echo $product['url'];?>">
          <img src="<?php echo $product['goods_img']?>">
          <?php if(!empty($product['ml_img'])){ ?>
          <img src="<?php echo $product['ml_img']?>" class="hide">
          <?php } ?>
        </a>
        <p>
          <a href="<?php echo $product['url'];?>"><?php echo $product['name'];?></a>
        </p>
        <p>
          <?php
            if($product['attribute_type']==2){
              if($product['product_type']){
                echo currency($product['sell_price']);
              }else{
                echo currency($product['advanced_price']);
              }
            }elseif($product['attribute_type']==1){
              echo currency($product['custom_price']);
            }
          ?>
        </p>
      </li>
      <?php
          endforeach;
        endif;
      ?>
    </ul>
  </div>
  <span class="fa fa-2x fa-chevron-left carousel-control-prev js-carousel-control-prev"></span>
  <span class="fa fa-2x fa-chevron-right carousel-control-next js-carousel-control-next"></span>
</div>
<!-- build:js /statics/front/pkg/js/carousel.js -->
<script src="/statics/front/js/plugins/carousel/jquery.jcarousel.min.js"></script>
<script src="/statics/front/js/plugins/carousel/jquery.jcarousel-swipe.min.js"></script>
<script src="/statics/front/js/scripts/carousel-list.js"></script>
<!-- endbuild -->
<!-- build:js /statics/front/pkg/js/product-details2.js -->
<script src="/statics/front/js/plugins/jquery.popupBox.js"></script>
<script src="/statics/front/js/scripts/product-details/product-details.js"></script>
<script src="/statics/front/js/scripts/slide.js"></script>
<!-- endbuild -->
<script>
function changePrice() {
	var goods = {};
	var goodsId  = <?php echo $productInfo['id']?>;
	var attr = getSelectedAttributes(document.forms['ECS_FORMBUY']);
	var qty = $('#goods_number').val();

	goods.pid = goodsId;
	goods.attr = attr;
	goods.qty = qty;

	$.post(url('product/getPrice'), {'post': $.toJSONString(goods)}, function(data) {
		var res = $.evalJSON(data);
		if (res.error > 0) {
			alert(res.message);
		} else {
			$('#goods_number').val(res.qty);
		}
	});
}

function changeAtt(t) {
	$(t).parent().children().each(function(){
		$(this).removeClass("cattsel");
		$(this).children('input').attr('checked', false);
	});

	$(t).addClass("cattsel");
	$(t).children('input').attr('checked', true);
	changePrice();
}

$(function() {
	var $goodsNum = $('#goods_number');

	$('.js-decrease').on('click', function() { //商品数量递减
		var qty = Number($goodsNum.val());
		if (qty > 1) {
			$goodsNum.val(qty - 1);
			changePrice();
		}
	});
	$('.js-increase').on('click', function() { //商品数量递增
		var qty = Number($goodsNum.val());
		$goodsNum.val(qty + 1);
		changePrice();
	});

	$goodsNum.on('blur', function() {
		var $this = $(this);
		var qty = parseInt($this.val());
		$this.val(qty);
		changePrice();
	});

  <?php if($productComment['count'] > 0):?>
  (function () {
    var _init = false;
    function customerReviews(page) {
      $.ajax({
        type: 'GET',
        url: '/product/reviews',
        data: {'pid':<?php echo $productInfo['id'];?>, 'p': page},
        success: function (content) {
          if(_init)
            $(".comment-num").trigger("click");
          _init = true;
          $('.product-comment-title').nextAll().remove();
          $('.product-comment-title').after(content);
        }
      })
    }
    customerReviews(1);
  }());
  <?php endif;?>
});
</script>
<?php include THEMES_PATH.'public/footer2.phtml';?>
<?php include THEMES_PATH.'public/after_body.phtml';?>